<?php
namespace app\decorate\model;
use app\BaseModel;
use think\facade\Db;



class Customer extends BaseModel
{
    //定义表名 风格表
    protected $name = 'longbing_card_decorate_customer_service';

    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 客服列表
     */
    public function dataList($dis,$mapor,$page = 10){
        $data = $this->where($dis) ->where(function ($query) use ($mapor){
            $query->whereOr($mapor);
        })->status(-1)->order('id desc')->paginate($page)->toArray();
        return $data;
    }


    /**
     * @param $data
     * @return int|string
     * 添加客服
     */
    public function dataAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $res = $this->insert($data);
        return $res;
    }
    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑风格
     */
    public function dataUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }
    /**
     * @param $dis
     * @return AdminCate
     * 客服详情
     */
    public function dataInfo($dis){
        $data = $this->where($dis)->status(-1)->find();
        return !empty($data)?$data->toArray():$data;
    }





}